<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/12/31 0031
 * Time: 10:07
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);


namespace app\common\business;
use app\common\lib\Show;
use app\common\validate\Cate as ValObj;
use app\common\model\MallCate as ModelObj;
use think\Exception;


class Cate extends Base
{
    /**
     * @var \app\common\validate\Goods
     */
    protected ValObj $valObj;
    /**
     * @var \app\common\model\MallGoods
     */
    protected ModelObj $modelObj;

    /**
     *
     */
    public function __construct()
    {
        $this->valObj = new ValObj();
        $this->modelObj = new ModelObj();
    }

    /**
     * 获取分类
     * @param array $where
     * @param string $field
     * @return array
     * @throws Exception
     */
    public function getCateList(array $where,string $field){

        try {
            $result = $this->modelObj->getModelByListToArray($where,$field,'sort desc,id desc');

        } catch (\Exception $e) {
            throw new Exception("查询失败");
        }

        return $result;
    }

    /**
     * 获取指定分类信息
     * @param array $where
     * @param string $field
     * @return void
     */
    public function  getCateInfo(array $where ,string $field){

        try {
            $result = $this->modelObj->getModelByInfo($where,$field);

        } catch (\Exception $e) {
            throw new Exception("查询失败");
        }

        return $result;
    }
}